package com.fly.service.Impl;

import com.fly.bean.Circuitry;
import com.fly.mapper.CircuityMapperO;
import com.fly.service.CircuitryServiceO;
import com.fly.util.Page;
import com.fly.vo.AndPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: Orchid
 * @Date: 2019/11/28 14:41
 * @Description:
 */
@Service
public class CircuitryServiceImpl implements CircuitryServiceO {

    @Autowired
    CircuityMapperO circuityMapperO;

    @Override
    public Circuitry queryCirById(Integer circuitryId) {

        return circuityMapperO.selectCirById(circuitryId);
    }

    @Override
    public String queryCirNameById(Integer circuitryId) {

        return circuityMapperO.selectCirNameById(circuitryId);
    }

    @Override
    public List<Circuitry> queryAllCir() {

        return circuityMapperO.selectAllCir();
    }

    @Override
    public List<Circuitry> queryCirByPage(Page page) {

        return circuityMapperO.selectCirByPage(page);
    }

    @Override
    public Integer queryCirAllCount() {

        return circuityMapperO.selectCirAllCount();
    }

    @Override
    public List<Circuitry> queryCirPageByNo(Circuitry circuitry, Page page) {

        //设置线路条件查询条件
        AndPageVO andPageVO = new AndPageVO();
        andPageVO.setCircuitry(circuitry);
        andPageVO.setPage(page);

        return circuityMapperO.selectCirPageByNo(andPageVO);
    }

    @Override
    public Integer queryCirCountPageByNo(Circuitry circuitry) {

        return circuityMapperO.selectCirCountPageByNo(circuitry);
    }

    @Override
    public Integer updateStateById(Circuitry circuitry) {

        return circuityMapperO.updateStateById(circuitry);
    }

    @Override
    public Integer querySysProIdById(Integer circuitryId) {

        return circuityMapperO.selectSysProIdById(circuitryId);
    }

    @Override
    public Boolean queryCountByNo(String circuitryNo) {

        Integer count = circuityMapperO.selectCountByNo(circuitryNo);

        if (count > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean updateCirById(Circuitry circuitry) {

        Integer isUp = circuityMapperO.updateCirById(circuitry);

        if (isUp > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean deleteCircuitryById(Integer circuitryId) {

        Integer isDelete = circuityMapperO.deleteCircuitryById(circuitryId);

        if (isDelete > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean addCircuitry(Circuitry circuitry) {

        Integer isAdd = circuityMapperO.insertCircuitry(circuitry);

        if (isAdd > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Integer queryCirByPoleActiveCount(Integer circuitryId) {

        return circuityMapperO.selectCirByPoleActiveCount(circuitryId);
    }

    @Override
    public Boolean queryCirIsUse(String circuitryNo) {

        Integer count = circuityMapperO.selectCirIsUse(circuitryNo);

        if (count > 0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public Integer queryIdByCirNo(String circuitryNo) {

        return circuityMapperO.selectIdByCirNo(circuitryNo);
    }

    @Override
    public Boolean queryCirTaskIsFinish(Integer circuitryId) {

        Integer count = circuityMapperO.selectCirTaskIsFinish(circuitryId);

        if (count > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean queryOtherNoCountByNo(Circuitry circuitry) {

        Integer count = circuityMapperO.selectOtherNoCountByNo(circuitry);

        if (count > 0){
            return true;
        }else {
            return false;
        }

    }

}
